Apparatus and Method for Efficient Identification of Code Similarity

ABSTRACT

A method for identifying similarity between query samples and stored samples in an efficiently maintained reference library may include receiving a binary query sample and processing the binary query sample via operations including producing a query sample fingerprint from the binary query sample, scoring the query sample fingerprint with each previously stored fingerprint in the reference library to produce a matching score, and for each previously stored fingerprint for which the matching score meets or exceeds a predetermined threshold, reporting a corresponding reference sample unique identifier associated with the previously stored fingerprint and the matching score. Each previously stored fingerprint in the reference library has been determined, prior to storage, as not being duplicative of another fingerprint in the reference library.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is related to and claims the benefit of U.S. patent application Ser. No. 14/925,301 filed on Oct. 28, 2015 and U.S. Provisional Application No. 62/072,544 filed on Oct. 30, 2014, the entire contents of each of which are hereby incorporated herein by reference.

TECHNICAL FIELD

Example embodiments generally relate to analysis techniques for determining code similarity and, in particular, relate to identification of related code variants in binaries and identification of near duplicates in text samples.

BACKGROUND

The easy and routine distribution of computer code in source and binary form, and the importance of those distributions, has engendered strongly-felt needs to identify code theft, code provenance, and the presence of malware. Each of these needs may be met, at least in part, by the ability to rapidly compare test code samples to a large library of reference code samples to detect reference samples similar to the test samples. In particular, there is a strong desire to recognize when incoming code binaries are variants of known examples of malware.

The most promising approaches to recognizing code similarity typically do so by transforming the code samples into streams of tokens. These tokens can represent source characters, words, functional names, op-codes, calls, or other features or can represent parallel features in code binaries. For example, some methods produce token streams of characters, similar to DNA streams, drawn from sections of code binaries. Other methods of code similarity detection may be based on token streams of op-codes. Still other methods operate based on streams of tokens drawn from source code, in which structural elements are reduced to single-letter tokens. Some solutions may describe methods based on tokens representing calls to system routines during runtime.

Concurrently, the internet has offered an explosion of text documents leading to a strongly-felt need to recognize similar passages of text for the purposes of detecting plagiarism in academic environments, establishing provenance, and reducing duplication. The most successful approaches to bulk detection of document similarity have also been based on converting document samples to token streams, with those tokens representing words or characters in the documents.

In some examples, each sample is converted to a token stream, from which n-grams are extracted to form a signature of the sample. A library of references is formed by recording the signatures of reference samples, together with identifying information. To examine a test sample, its signature is constructed in a parallel manner, and the signature is compared to those in the library. References whose signatures are sufficiently similar to the signature of the test sample are reported as similar.

An n-gram is an n-long sequence of consecutive tokens drawn from a stream of tokens. Representing a token stream by its constituent n-grams makes a uniform basis of comparison of token streams, provides tolerance of small differences between token streams, and offers rapid computation. One can also easily represent n-grams by their numeric hash values, thereby saving space and providing a numeric index or key into tables for recording and look-up purposes. Accordingly, one can construct signatures of token streams using n-gram hash values, rather than using n-grams directly.

Despite the strongly-felt needs and considerable work in this area, conventional methods generally do not offer methods that achieve a processing speed and library capacity that can address the anticipated need for rapid bulk processing of input samples against a voluminous library of references.

Accordingly, it may be desirable to continue to develop improved and/or more efficient mechanisms by which protection against malware may be provided. Moreover, in some cases, the detection of related code variants in binaries outside the context of malware detection may also be useful.

BRIEF SUMMARY OF SOME EXAMPLES

Accordingly, some example embodiments may enable the provision of a relatively scalable and efficient solution for addressing the issues described above. In one example embodiment, an apparatus for identifying similarity between query samples and stored samples in an efficiently maintained reference library is provided. The apparatus may include processing circuitry configured to execute instructions for receiving a first threshold and a second threshold, receiving a plurality of binary reference samples, and processing each reference sample of the plurality of reference samples. The processing may include operations of assigning each reference sample a respective unique identifier, producing a reference sample fingerprint for each reference sample, and registering each respective unique identifier to reference sample fingerprint pair in a reference library. The registering may include scoring the reference sample fingerprint with each previously stored fingerprint in the reference library to produce a first matching score, if the first matching score meets or exceeds the first threshold for a previously stored fingerprint, determining the reference sample fingerprint to be a duplicate of the previously stored fingerprint and recording only a unique identifier associated with the reference sample fingerprint in the reference library where the unique identifier is marked as a duplicate of the previously stored fingerprint, and otherwise, if the first matching score is less than the first threshold, storing a corresponding reference sample unique identifier to reference sample fingerprint pair in the reference library.

In another example embodiment, a method for identifying similarity between query samples and stored samples in an efficiently maintained reference library is provided. The method may include receiving a binary query sample and processing the binary query sample via operations including producing a query sample fingerprint from the binary query sample, scoring the query sample fingerprint with each previously stored fingerprint in the reference library to produce a matching score, and for each previously stored fingerprint for which the second matching score meets or exceeds the threshold, reporting a corresponding reference sample unique identifier associated with the previously stored fingerprint and the matching score. Each previously stored fingerprint in the reference library has been determined, prior to storage, as not being duplicative of another fingerprint in the reference library.

BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWING(S)

Having thus described the invention in general terms, reference will now be made to the accompanying drawings, which are not necessarily drawn to scale, and wherein:

FIG. 1 illustrates a functional block diagram of a system that may be useful in connection with identification of related code variants in binaries according to an example embodiment;

FIG. 2 illustrates a functional block diagram of an apparatus that may be useful in connection with identification of related code variants in binaries according to an example embodiment;

FIG. 3 illustrates a series of process flows that may be supported by an apparatus or system configured in accordance with an example embodiment;

FIG. 4 illustrates one example of a preprocessing process that may be employed by a fingerprint generator of an example embodiment;

FIG. 5 illustrates an example of fingerprints indexed by the 4-grams they include in accordance with an example embodiment;

FIG. 6 illustrates a block diagram of components of the scoring module in accordance with an example embodiment;

FIG. 7 illustrates a flow diagram of one example process employing an exemplary embodiment;

FIG. 8 illustrates a process flow showing details of one of the operations of FIG. 7 according to an example embodiment;

FIG. 9 illustrates a process flow showing alternative details of one of the operations of FIG. 7 according to an example embodiment;

FIG. 10 illustrates a process flow showing details of another one of the operations of FIG. 7 according to an example embodiment;

FIG. 11 illustrates a process flow showing details of one of the operations of FIG. 10 according to an example embodiment;

FIG. 12 illustrates a process flow showing details of one of the operations of FIG. 7 according to an example embodiment;

FIG. 13 illustrates a process flow showing alternatives to some of the operations of FIG. 7 according to an example embodiment;

FIG. 14 illustrates a process flow showing alternatives to some of the operations of FIG. 7 according to an example embodiment;

FIG. 15 illustrates a method of identifying related code variants according to an example embodiment;

FIG. 16 illustrates a series of process flows that may be supported by an apparatus or system including a library manager configured in accordance with an example embodiment; and

FIG. 17 illustrates a method for identifying similarity between query samples and stored samples in an efficiently maintained reference library according to an example embodiment.

DETAILED DESCRIPTION

Some example embodiments now will be described more fully hereinafter with reference to the accompanying drawings, in which some, but not all example embodiments are shown. Indeed, the examples described and pictured herein should not be construed as being limiting as to the scope, applicability or configuration of the present disclosure. Rather, these example embodiments are provided so that this disclosure will satisfy applicable legal requirements. Like reference numerals refer to like elements throughout.

Some example embodiments may relate to the provision of malicious software detection. However, it should also be appreciated that example embodiments may further provide utility in connection with identifying related code variants in other contexts as well including the detection of near duplicates in text samples. In some embodiments, binaries associated with software or content may be analyzed on the basis of a lossy compression that is employed to generate a fingerprint of the functional components of binaries. This fingerprint may be similar to a DNA code of the binaries, which essentially acts as a transformation technique that compresses the input by as much as 95% with the results being represented as a sequence of letters resembling DNA strings. Such a lossy compression may enable the relatively efficient and accurate clustering of related malware and may also support recursive analysis of malware variants in an automated system. Thus, for example, worms, viruses and other malware may be detected to improve the security and stability of platforms that operate on executable code, even when slight changes have been made to the code. Moreover, embodiments may be applicable to personal computer (PC) programs, mobile terminal programs or executable code for use with any execution platform. Additionally, based on the substantial compression that is attainable by developing these “fingerprints” or “DNA” strings, this type of transformation will generally obscure variations that are unimportant, while preserving sufficient specificity to separate functions of different nature. Given a library of reference functions, an unknown function can be transformed similarly, and matches or near matches with contents of the library may reveal the nature of the unknown.

To be most useful, the method of comparison should permit bulk processing of unknowns against a sizeable library in a timely fashion. Accordingly, by further processing the “fingerprints” or “DNA” strings generated by an example embodiment with n-gram based scoring, substantial savings may be achieved in terms of both space and time with little degradation of the scores. After the n-gram based transformation is accomplished on the code “fingerprints” or “DNA” strings, rather than recording the n-grams themselves, an example embodiment may record integer hashes of consecutive n-grams. Resultant samples may be partitioned by length so that only those samples having lengths that could result in interesting scores may actually be compared. As such, for example, a dictionary of reference samples may be partitioned into cells in a strategic way, as described in greater detail below. The partitioning may lead to speed increases since the number of candidate matches will be likely to be reduced for each unknown. In some embodiments, the set of n-gram hash values may also be decimated by some number (e.g., k), meaning that a fraction of about 1/k of the values will be kept. However, rather than selecting every kth value, or selecting one kth at random, an example embodiment may choose n-gram hash values that are divisible by k. The decimation may enable further memory and CPU time savings.

The makers of malware often make variants of the same code to create new malware. Scanning software that is typically used to identify malware often does some sort of hash of both known malware and new code being scanned. When comparing, typical scanning software looks for an exact match of the hashes. This makes avoiding the scan relatively easy for experienced malware makers. The scoring method described above and herein can be very useful in connection with providing an efficient way to identify malware that is a variant of a previously known piece of malware without this limitation. In this regard, the scoring method described above can efficiently identify matching DNA or fingerprints that can catch matches that wouldn't be caught by scanning products that require exact matches of the hashes. However, the scoring method still requires a library to be maintained of the DNA or fingerprints of the malware, and such library could grow to a very large size over time if each time a new piece of malware is detected it is added to the library. Moreover, as the library grows, there are also more chances for additional matches to be detected when a new variant actually shares DNA with many other samples stored in the library. Each communication associated with identifying these matches consumes processing power and bandwidth.

Accordingly, an example embodiment is further provided to assist in managing the size of the library so that the library is efficiently maintained. In this regard, instead of having a fingerprint or DNA of every sample associated with malware in the library, the library can be maintained to ensure that duplicates (or near duplicates) of existing samples are not added to the library. Thus, the library can be kept smaller and still (using the matching and scoring methods described herein) effectively identify malware based on DNA or fingerprints. The principle is that if (under the scoring methods described herein) sample A scores well with sample B, and sample B scores well with sample C, then sample A will also score well with sample C. Thus, instead of keeping a fingerprint or DNA for both samples A and B in the context of an inquiry as to the risk associated with sample C, it may be possible to keep only sample A and still get a good matching score with sample C. This keeps the library smaller (since sample B is not stored) and also results in less bandwidth consumption (since processing and communications associated with determining a match between sample B and C is not necessary, and yet this process does not sacrifice efficacy.

An example embodiment will now be described in reference to FIG. 1, which illustrates an example system in which an embodiment of the present invention may be employed. As shown in FIG. 1, a system 10 according to an example embodiment may include one or more client devices (e.g., clients 20). Notably, although FIG. 1 illustrates three clients 20, it should be appreciated that a single client or many more clients 20 may be included in some embodiments and thus, the three clients 20 of FIG. 1 are simply used to illustrate a potential for a multiplicity of clients 20 and the number of clients 20 is in no way limiting to other example embodiments. In this regard, example embodiments are scalable to inclusion of any number of clients 20 being tied into the system 10. Furthermore, in some cases, some embodiments may be practiced on a single client without any connection to the system 10.

The example described herein will be related to an asset comprising a computer or analysis terminal to illustrate one example embodiment. However, it should be appreciated that example embodiments may also apply to any asset including, for example, any programmable device that is capable of receiving and analyzing files as described herein.

The clients 20 may, in some cases, each be associated with a single organization, department within an organization, or location (i.e., with each one of the clients 20 being associated with an individual analyst of an organization, department or location). However, in some embodiments, each of the clients 20 may be associated with different corresponding locations, departments or organizations. For example, among the clients 20, one client may be associated with a first facility of a first organization and one or more of the other clients may be associated with a second facility of either the first organization or of another organization.

Each one of the clients 20 may include or otherwise be embodied as computing device (e.g., a computer, a network access terminal, a personal digital assistant (PDA), cellular phone, smart phone, or the like) capable of communication with a network 30. As such, for example, each one of the clients 20 may include (or otherwise have access to) memory for storing instructions or applications for the performance of various functions and a corresponding processor for executing stored instructions or applications. Each one of the clients 20 may also include software and/or corresponding hardware for enabling the performance of the respective functions of the clients 20 as described below. In an example embodiment, one or more of the clients 20 may include a client application 22 configured to operate in accordance with an example embodiment of the present invention. In this regard, for example, the client application 22 may include software for enabling a respective one of the clients 20 to communicate with the network 30 for requesting and/or receiving information and/or services via the network 30. Moreover, in some embodiments, the information or services that are requested via the network may be provided in a software as a service (SAS) environment. The information or services receivable at the client applications 22 may include deliverable components (e.g., downloadable software to configure the clients 20, or information for consumption/processing at the clients 20). As such, for example, the client application 22 may include corresponding executable instructions for configuring the client 20 to provide corresponding functionalities for processing and/or analyzing binary code as described in greater detail below.

The network 30 may be a data network, such as a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN) (e.g., the Internet), and/or the like, which may couple the clients 20 to devices such as processing elements (e.g., personal computers, server computers or the like) and/or databases. Communication between the network 30, the clients 20 and the devices or databases (e.g., servers) to which the clients 20 are coupled may be accomplished by either wireline or wireless communication mechanisms and corresponding communication protocols.

In an example embodiment, devices to which the clients 20 may be coupled via the network 30 may include one or more application servers (e.g., application server 40), and/or a database server 42, which together may form respective elements of a server network 32. Although the application server 40 and the database server 42 are each referred to as “servers,” this does not necessarily imply that they are embodied on separate servers or devices. As such, for example, a single server or device may include both entities and the database server 42 could merely be represented by a database or group of databases physically located on the same server or device as the application server 40. The application server 40 and the database server 42 may each include hardware and/or software for configuring the application server 40 and the database server 42, respectively, to perform various functions. As such, for example, the application server 40 may include processing logic and memory enabling the application server 40 to access and/or execute stored computer readable instructions for performing various functions. In an example embodiment, one function that may be provided by the application server 40 may be the provision of access to information and/or services related to operation of the terminals or computers with which the clients 20 are associated. For example, the application server 40 may be configured to provide for storage of information descriptive of certain binary codes associated with software or content being analyzed (e.g., in the database server 42). The information may include a “fingerprint” and/or “DNA” code associated with the binary code that may be useful in the analysis described herein by clients 20 for use in connection with practicing example embodiments. Alternatively or additionally, the application server 40 may be configured to provide analytical tools for use by the clients 20 in accordance with example embodiments.

In some embodiments, for example, the application server 40 may therefore include an instance of a code analyzer 44 comprising stored instructions for handling activities associated with practicing example embodiments as described herein. As such, in some embodiments, the clients 20 may access the code analyzer 44 online and utilize the services provided thereby. However, it should be appreciated that in other embodiments, the code analyzer 44 may be provided from the application server 40 (e.g., via download over the network 30) to one or more of the clients 20 to enable recipient clients to instantiate an instance of the code analyzer 44 for local operation. As yet another example, the code analyzer 44 may be instantiated at one or more of the clients 20 responsive to downloading instructions from a removable or transferable memory device carrying instructions for instantiating the code analyzer 44 at the corresponding one or more of the clients 20. In such an example, the network 30 may, for example, be a peer-to-peer (P2P) network where one of the clients 20 includes an instance of the code analyzer 44 to enable the corresponding one of the clients 20 to act as a server to other clients 20.

In an example embodiment, the application server 40 may include or have access to memory (e.g., internal memory or the database server 42) for storing instructions or applications for the performance of various functions and a corresponding processor for executing stored instructions or applications. For example, the memory may store an instance of the code analyzer 44 configured to operate in accordance with an example embodiment of the present invention. In this regard, for example, the code analyzer 44 may include software for enabling the application server 40 to communicate with the network 30 and/or the clients 20 for the provision and/or receipt of information associated with performing activities as described herein. Moreover, in some embodiments, the application server 40 may include or otherwise be in communication with an access terminal (e.g., a computer including a user interface) via which analysts may interact with, configure or otherwise maintain the system 10.

As such, the environment of FIG. 1 illustrates an example in which provision of content and information associated with the analysis such as, for example, security or intelligence operations may be accomplished by a particular entity (namely the code analyzer 44 residing at the application server 40). However, it should be noted again that the code analyzer 44 could alternatively handle provision of content and information within a single organization. Thus, in some embodiments, the code analyzer 44 may be embodied at one or more of the clients 20 and, in such an example, the code analyzer 44 may be configured to handle provision of content and information associated with analytical tasks that are associated only with the corresponding single organization. Access to the code analyzer 44 may therefore be secured as appropriate for the organization involved and credentials of individuals or analysts attempting to utilize the tools provided herein.

An example embodiment of the invention will now be described with reference to FIG. 2. FIG. 2 shows certain elements of an apparatus for provision of identification of related code variants in binaries according to an example embodiment. The apparatus of FIG. 2 may be employed, for example, on a client (e.g., any of the clients 20 of FIG. 1) or a variety of other devices (such as, for example, a network device, server, proxy, or the like (e.g., the application server 40 of FIG. 1)). Alternatively, embodiments may be employed on a combination of devices. Accordingly, some embodiments of the present invention may be embodied wholly at a single device (e.g., the application server 40 or one or more clients 20) or by devices in a client/server relationship (e.g., the application server 40 and one or more clients 20). Furthermore, it should be noted that the devices or elements described below may not be mandatory and thus some may be omitted in certain embodiments.

Referring now to FIG. 2, an apparatus for provision of identification of related code variants in binaries is provided. The apparatus may be an embodiment of the code analyzer 44 or a device hosting the code analyzer 44. As such, configuration of the apparatus as described herein may transform the apparatus into the code analyzer 44. In an example embodiment, the apparatus may include or otherwise be in communication with processing circuitry 50 that is configured to perform data processing, application execution and other processing and management services according to an example embodiment of the present invention. In one embodiment, the processing circuitry 50 may include a storage device 54 and a processor 52 that may be in communication with or otherwise control a user interface 60 and a device interface 62. As such, the processing circuitry 50 may be embodied as a circuit chip (e.g., an integrated circuit chip) configured (e.g., with hardware, software or a combination of hardware and software) to perform operations described herein. However, in some embodiments, the processing circuitry 50 may be embodied as a portion of a server, computer, laptop, workstation or even one of various mobile computing devices. In situations where the processing circuitry 50 is embodied as a server or at a remotely located computing device, the user interface 60 may be disposed at another device (e.g., at a computer terminal or client device such as one of the clients 20) that may be in communication with the processing circuitry 50 via the device interface 62 and/or a network (e.g., network 30).

The user interface 60 may be in communication with the processing circuitry 50 to receive an indication of a user input at the user interface 60 and/or to provide an audible, visual, mechanical or other output to the user. As such, the user interface 60 may include, for example, a keyboard, a mouse, a joystick, a display, a touch screen, a microphone, a speaker, a cell phone, or other input/output mechanisms. In embodiments where the apparatus is embodied at a server or other network entity, the user interface 60 may be limited or even eliminated in some cases. Alternatively, as indicated above, the user interface 60 may be remotely located.

The device interface 62 may include one or more interface mechanisms for enabling communication with other devices and/or networks. In some cases, the device interface 62 may be any means such as a device or circuitry embodied in either hardware, software, or a combination of hardware and software that is configured to receive and/or transmit data from/to a network and/or any other device or module in communication with the processing circuitry 50. In this regard, the device interface 62 may include, for example, an antenna (or multiple antennas) and supporting hardware and/or software for enabling communications with a wireless communication network and/or a communication modem or other hardware/software for supporting communication via cable, digital subscriber line (DSL), universal serial bus (USB), Ethernet or other methods. In situations where the device interface 62 communicates with a network, the network may be any of various examples of wireless or wired communication networks such as, for example, data networks like a Local Area Network (LAN), a Metropolitan Area Network (MAN), and/or a Wide Area Network (WAN), such as the Internet.

In an example embodiment, the storage device 54 may include one or more non-transitory storage or memory devices such as, for example, volatile and/or non-volatile memory that may be either fixed or removable. The storage device 54 may be configured to store information, data, applications, instructions or the like for enabling the apparatus to carry out various functions in accordance with example embodiments of the present invention. For example, the storage device 54 could be configured to buffer input data for processing by the processor 52. Additionally or alternatively, the storage device 54 could be configured to store instructions for execution by the processor 52. As yet another alternative, the storage device 54 may include one of a plurality of databases (e.g., database server 42) that may store a variety of files, contents or data sets. Among the contents of the storage device 54, applications (e.g., client application 22 or service application 42) may be stored for execution by the processor 52 in order to carry out the functionality associated with each respective application.

The processor 52 may be embodied in a number of different ways. For example, the processor 52 may be embodied as various processing means such as a microprocessor or other processing element, a coprocessor, a controller or various other computing or processing devices including integrated circuits such as, for example, an ASIC (application specific integrated circuit), an FPGA (field programmable gate array), a hardware accelerator, or the like. In an example embodiment, the processor 52 may be configured to execute instructions stored in the storage device 54 or otherwise accessible to the processor 52. As such, whether configured by hardware or software methods, or by a combination thereof, the processor 52 may represent an entity (e.g., physically embodied in circuitry) capable of performing operations according to embodiments of the present invention while configured accordingly. Thus, for example, when the processor 52 is embodied as an ASIC, FPGA or the like, the processor 52 may be specifically configured hardware for conducting the operations described herein. Alternatively, as another example, when the processor 52 is embodied as an executor of software instructions, the instructions may specifically configure the processor 52 to perform the operations described herein.

In an example embodiment, the processor 52 (or the processing circuitry 50) may be embodied as, include or otherwise control the code analyzer 44, which may be any means such as a device or circuitry operating in accordance with software or otherwise embodied in hardware or a combination of hardware and software (e.g., processor 52 operating under software control, the processor 52 embodied as an ASIC or FPGA specifically configured to perform the operations described herein, or a combination thereof) thereby configuring the device or circuitry to perform the corresponding functions of the code analyzer 44 as described below.

The code analyzer 44 manager may include tools to facilitate the creation and distribution of analysis results via the network 30. In an example embodiment, the analysis results may include reports indicating threats identified and/or potential threats that merit further analysis. The reports may be generated on the basis of analytical processing performed by the code analyzer 44. In this regard, the code analyzer 44 may be configured to process binary code or codes that are provided thereto and compare the code or codes of content to be queried or analyzed to a library of known malware codes so that matches or near matches can be identified. In some embodiments, the comparison may actually be performed on a compressed representation of the code, and the compressed representation of the code may be referred to as a “fingerprint” or “DNA” of the code. The comparison performed may identify code or code portions that correspond to executable code that is known malware, or that appears to be a modified version of known malware.

In some embodiments, the code analyzer 44 may further include one or more components that contribute to the performance of the tasks or operations associated therewith. For example, as shown in FIG. 2, the code analyzer 44 may include a fingerprint generator 110, a fingerprint filter 120, and/or a scoring module 130. Each of the code analyzer 44, the fingerprint generator 110, the fingerprint filter 120, and the scoring module 130 may be any means such as a device or circuitry operating in accordance with software or otherwise embodied in hardware or a combination of hardware and software (e.g., processor 52 operating under software control, the processor 52 embodied as an ASIC or FPGA specifically configured to perform the operations described herein, or a combination thereof) thereby configuring the device or circuitry to perform the corresponding functions of the code analyzer 44, the fingerprint generator 110, the fingerprint filter 120, and the scoring module 130, respectively, as described herein.

In an example embodiment, the fingerprint generator 110 may be configured to generate one or more fingerprints based on a binary file being analyzed. A “fingerprint” may be a representation of the code that is generated in accordance with a specific process performed in connection with an example embodiment to form a compressed representation of the binary file or portions thereof. In some cases, the compressed representation may be formed using a lossy compression technique that is executed with respect to functional portions of the binary file being analyzed. In some embodiments, the fingerprint may be generated based on a DNA sequencer type of operation via which the fingerprint generator 110 operates to ignore changes in file size (e.g., via use of padding) so that only executable portions are considered to identify the constituent portions of the binary file. The fingerprint that is generated may be unlike biological DNA in that the fingerprint, although descriptive of components of the binaries, cannot be used to reconstruct the original entity that forms the basis for the fingerprint. Thus, for example, the fingerprint cannot become a malware factory and the malware is never afforded access to a potential execution environment. Instead, the fingerprint generator 110 simply treats binary files as data and the fingerprint is generated without any portions of the binary files being executed.

The fingerprint filter 120 may be configured to filter or select fingerprints that may be similar to query fingerprints associated with a query file as described in greater detail below. In this regard, for example, the database server 42 may store a plurality of fingerprints associated with known binaries of interest (e.g., malware), and these known binaries of interest (and their fingerprints) may form the basis for comparison with query files and their respective fingerprints to identify similarities therebetween. Thus, for example, the fingerprint filter 120 may be configured to use n-gram filtering, or some other suitable comparison technique, to identify a plurality of fingerprints that are similar to one or more query fingerprints associated with a query file. The scoring module 130 may be configured to employ a scoring algorithm to generate scores that are indicative of a similarity or degree of correlation between the query fingerprints and the selected or filtered fingerprints that were judged to be similar based on operation of the fingerprint filter 120.

In an example embodiment, the code analyzer 44 executes a process for identifying related code variants in binaries using the components described above. FIG. 3 illustrates process flows in accordance with an example embodiment. As shown in FIG. 3, reference binaries 200 may be provided based on past experience. The reference binaries 200 may be binary files that are or include malware. The reference binaries 200 may be preprocessed at operation 210. The preprocessing at operation 210 may generate a plurality of reference code fingerprints 220 (e.g., via operation of the fingerprint generator 110) that may be stored in a code fingerprint database 230 (e.g., the database server 42). Although not required, analyst intelligence information 240 may be added to one or more of the reference code fingerprints 220 at operation 250. In some cases, the analyst intelligence information 240 may include information about portions of each binary such as who wrote the code, what function the code portion performs, and/or the like.

The reference code fingerprints 220 remain in the code fingerprint database 230 and can be supplemented with additional fingerprints to grow the size of and otherwise update the database. Thus, the code fingerprint database 230 may be updated to add (or subtract) reference code fingerprints as appropriate over time. The addition of reference code fingerprints 220 may be accomplished by the performance of preprocessing at operation 210, or by direct importation of fingerprints. Moreover, in some embodiments, after code variants are identified via operation of the code analyzer 44 as described herein, fingerprints associated with code variants that have been identified may be added to the code fingerprint database 230.

In order to identify code variants, example embodiments may analyze new binary files 260 to determine whether they include malware. The analysis of such new binary files 260 may be accomplished responsive to conversion (via preprocessing similar to that accomplished in operation 210) of the new binary files 260 to corresponding multiple query fingerprints 270. After conversion, the reference code fingerprints 220 may be filtered at operation 280 to enable identification or selection of one or more potentially relevant code fingerprints 284. The filtering may be accomplished by the fingerprint filter 120 described above. In this regard, the selection of potentially relevant code fingerprints 284 may be accomplished using n-gram matching. Thereafter, a similarity score 290 may be determined at operation 294 for each of the potentially relevant code fingerprints 284 (e.g., via operation of the scoring module 130). The similarity score may be determined based on the content of the potentially relevant code fingerprints 284 as compared to the query fingerprints 270. As a result of the operations of FIG. 3, an efficient search may be conducted to determine which parts of a query file (e.g., the new binary file 260) are similar (and/or which files are similar). In particular, example embodiments may be scalable to large amounts of data so that large amounts of data can be successfully and quickly processed to find code variants, even if significant portions of the code have been modified.

The preprocessing (operation 210) of binary files to generate a fingerprint (e.g., a reference fingerprint or a query fingerprint) may be conducted in any suitable manner. However, according to an example embodiment, the preprocessing may be accomplished by breaking binary code into individual and comparable pieces or portions. These portions (i.e., code portions) may then be converted into a suitable form for efficient and accurate similarity computation. In an example embodiment, the conversion that occurs may be provided via a compressive mapping that is derived on the basis of functional portions of the binary code. As such, for example, relatively unchanging portions of the binary code that encapsulate the function and origin of the binary code may be extracted (e.g., by the fingerprint generator 110). Thus, a single binary code file may generate a plurality of different parts that reflect function, and those parts may each be processed into a compressed representation.

In an example embodiment, the compressed representation may employ lossy compression so that variance recognition may be enhanced while still using fast and efficient processing. As such, the fingerprints that are generated are considered to be a relatively low noise representation of the functional code portions with which each is associated. In some embodiments, the compressed representation that is performed employs an alphabet for compressive mapping based on functionally descriptive portions of the binary code.

FIG. 4 illustrates one example of a preprocessing process that may be employed by the fingerprint generator 110 of an example embodiment. As shown in FIG. 4, binary code 300 may initially be converted into a canonical source code 310 at operation 320. As such, the binary code 300 may be converted into some canonical, architecture-independent representation. In some embodiments, the representation may be source code, accomplished by using a decompiler at operation 320. However, in some cases, the representation may be a functional representation that is an abstracted functional representation (such as code flow or data flow graphs). Essentially, any abstraction of the function may form an example of functional representation code that may be used in this context. Thus, as used herein, references to source code should be understood to be examples of functional representation code that may be employed in some embodiments. Thereafter, at operation 330, the source code generated by operation 320 may be broken into portions based on function. Each functional portion may become a separate, conceptual piece of the binary code. Accordingly, an output of operation 330 may be a plurality of source code functions 340 as shown in FIG. 4. During operation 350, tokens may be applied to identify or represent shadows of the executables compressively. Accordingly, during operation 350, each function is itself then broken down into smaller units that are represented as function source code tokens 360 of the code. The tokens may be individual symbols of the source code as defined by a relevant language. Some examples of tokens may include the name of a type, the name of a variable, a constant value (e.g., “80031”), or a symbol (e.g., “,”). The order in which the tokens occur is maintained during operation 350.

Thereafter, at operation 370, each token is mapped to a compact symbol or alphabet character to define a fingerprint 380 (or functional DNA string) as shown in FIG. 4. In general, the mapping is not a one-to-one mapping. Many tokens can map to the same character, and some tokens may be omitted. However, a one-to-one mapping could be employed in some embodiments. The result of operation 370 may be a string of characters for each function. The string of characters may be considered to be a code fingerprint, or a function-DNA string.

The ability to preprocess binaries to generate code fingerprints (or function-DNA strings) may enable the code analyzer 44 to search a new binary to determine whether any code variants exist therein. In this regard, the code analyzer 44 is configured to break all binary code into functional portions and generate a compressed representation of such functional portions that can be mapped to a compact symbol to generate code fingerprints for the binaries. These code fingerprints can then be compared to determine variations. However, in an effort to enable a more efficient comparison, it may be desirable to only compare a query fingerprint to a limited number of potentially relevant code fingerprints. Thus, the potentially relevant code fingerprints may be first identified using filtering (e.g., via the fingerprint filter 120). The objective of filtering in accordance with one example embodiment may be to collect potentially relevant reference fingerprints from the fingerprint database. Although filtering may be optional, its employment may substantially increase searching efficiency by eliminating irrelevant DNA-strings from the search. An alternative may be to extract all function-DNA strings from the database and compute a similarity score for each one. However, this can require large amounts of processing power for a large fingerprint database.

To enable filtering, features of a reference-function-DNA-string (e.g., a reference fingerprint) may be identified and the strings may be indexed according to the features. For example, the fingerprints may be stored in data structures such that one may be enabled to obtain all of the function-DNA-strings that have a particular feature relatively quickly. One example of a feature that can be used for indexing is an n-gram. An n-gram is a sequence of n consecutive characters. FIG. 5 illustrates fingerprints indexed by the 4-grams they include. Conceptually, each 4-gram can be thought of as a key (e.g., keys 400, 410 and 420) that has all of the function-DNA-strings (e.g., strings 402, 404, 406, 412, 414, 422, 424 and 426), that contain that 4-gram stored with it, so the corresponding strings can be retrieved quickly.

Example embodiments filter potentially relevant results for each query function-DNA-string. In this regard, for example, features of interest may be identified from a query fingerprint. Then all of the reference fingerprints that also contain m of those features may be collected using the index. For example, if the key 410 is a 4-gram defined as ABBB, then fingerprints including the 4-gram such as strings 412 and 414 may be collected. To reduce the size of the index and increase efficiency, the index may omit some features. For example, the index may omit extremely common 4-grams because such common 4-grams may cause the filtering step to collect many reference fingerprints. In any case, if filtering is employed, only a selected number of potentially relevant fingerprints may be further processed for similarity determinations by operation of the scoring module 130.

Similarity computation by the scoring module 130 may be accomplished after binaries have been preprocessed into the function-DNA-strings or code fingerprints as described above. If filtering is performed, the similarity computation may further be performed after potentially relevant code fingerprints have been selected. The specific computation used for determining a similarity score at the scoring module 130 may vary based on the desires of the system designer. However, in one example embodiment, scoring may be accomplished using a DNA-sequencing algorithm.

As mentioned above, the scoring of an example embodiment may be accomplished using n-gram scoring in combination with hashing, partitioning and decimation. Accordingly, the scoring module 130 of an example embodiment may further include various functional components instantiated by configuring the processing circuitry 50 to perform the various functions associated with each functional component. FIG. 6 illustrates a block diagram of various components of the scoring module 130 in accordance with an example embodiment. As shown in FIG. 6, the scoring module 130 may include an n-gram scorer 500, a hash generator 510, a partitioning agent 520, and a decimator 530. The n-gram scorer 500, the hash generator 510, the partitioning agent 520, and the decimator 530 may each be embodied by configuration of the processing circuitry 50 as described above.

In an example embodiment, the n-gram scorer 500 may be configured to generate n-gram scores. An n-gram may be an n-long sequence of consecutive symbols. Thus, in an example embodiment, the n-gram may be a sequence of letters drawn from a token sequence that corresponds to the DNA sequence or fingerprint described above. In representing a sequence by n-grams, the number of times each n-gram occurred in a sequence, and perhaps also the locations of such occurrences may be recorded. Alternatively or additionally, a sequence could merely be represented by the set of n-grams that are found in it. As an example, suppose that an unknown (i.e., an unknown code, text or portion thereof) is represented by a set of n-grams U={u₁, u₂, . . . , u_(u)} and a reference is represented by a set of n-grams R={r₁, r₂, . . . , r_(r)}. It may be possible to compare the reference and unknown by using Jaccard similarity:

${{J\left( {U,R} \right)} = {\frac{{U\bigcap R}}{{U\bigcup R}} = \frac{c}{u + r - c}}},$

where c=|U∩R|. This similarity measure ranges from zero (no intersection) to one (equal sets). This score, i.e., the n-gram score, may be approximated by fast methods that, although some accuracy may be sacrificed, generally produce satisfactory results.

In an example embodiment, rather than recording the n-grams themselves, it may be preferable to record instead integer hashes of the n-grams. This may be an improvement from a storage space perspective since the integer may take less space than an n-gram of even moderate length. Additionally, the integer may serve directly as a table index. Because each n-gram may be similar to its predecessor, hashing of consecutive n-grams may be made very efficient by recursive calculation. As such, by judicious choice of hash function, the hash of the current n-gram may be obtained from the hash of the previous n-gram by including the effect of the new symbol and removing the effect of the symbol being dropped. The hash generator 510 may be configured to obtain the hash of n-grams for use in an example embodiment. As an example, suppose that a sample S contains distinct n-grams {g₁, g₂, . . . , g_(L)}. Using a hash function h that maps n-grams to integers, S can be recorded in table T by posting the index (identifier) of S in T at positions {h(g₁), h(g₂), . . . , h(g_(L))}. After recording a library of samples in T, each entry in T will contain a list of samples holding an n-gram that hashes to that entry. To score an unknown sample string against the reference samples, it is only necessary to hash the n-grams in the unknown (e.g., using the hash generator 510), look each up in T, and obtain both the candidate references that might match (that is, any that occur in the entries examined), and the number of common n-grams. Such a hashing scheme may enable the Jaccard score J to be evaluated with the caveat that the n-gram hashes may collide. Since each score derives from many n-grams, the occasional collision is not likely to be a problem.

To illustrate an example, suppose that two samples whose n-gram sets are A and B, respectively, are compared. Without loss of generality, suppose that |B|=r|A, r≧1. Then the best Jaccard similarity score that could be achieved would be when A⊂B, in which case, J(A, B)=1/r. Generally, then, J(A, B)≦1/r. Now if there is only interest in sample pairs whose similarity is at least ρ, then all that would be needed is a comparison of A and B if r≦1/ρ, since larger size differences will guarantee rejection.

This suggests that it is possible to partition samples by length and only compare those samples whose lengths could result in interesting scores. The partitioning agent 520 may be configured to execute such partitioning for example embodiments. In particular, a dictionary of reference samples partitioned (e.g., via the partitioning agent 520) into cells may be created such that the ith cell contains all samples of length L satisfying ρ^(−i)≦L<ρ^(−(i+1)), i=0, 1, 2, . . . . An unknown of length L then has a nominal cell index i=└−log(L)/log(ρ)┘, but must be compared to unknowns in cells i, i−1, and i+1. As an example, if the threshold for an interesting score is ρ=0.5, then the reference space is partitioned into octaves—groups differing by a factor of 2 in length. If ρ=0.1, then the partition is by decades. Partitioning in this manner may further improve speed performance since, as mentioned above, the number of candidate matches is likely to be reduced for each unknown. In this context, the “length” of a sample means either the size of the sample's n-gram set or a proxy for that size such as the number of tokens in the sample.

It may not be necessary or desirable to compare every n-gram of the samples since each n-gram may say a great deal about its neighbors. Accordingly, it may seem sufficient to keep n-grams at a selected sampling frequency. In some cases, unless one is particularly unlucky, the type of spot checking that may be accomplished via this sampling of n-grams may achieve the same results (perhaps with some variance) as long as a sufficient number of n-grams are retained and those n-grams are somehow representative. Accordingly, it may be possible to employ the decimator 530 to decimate the n-gram hash set by some number k, meaning that a fraction of about 1/k of the values may be kept.

Although this is the case, it may not be desirable to simply take every kth value, since there may be a complete mismatch between two samples that differ only by the addition of one symbol at the front. It may also not be desirable to choose the kth value at random, since identical samples would be represented by different (even disjointed) sets of n-grams. Accordingly, some embodiments may adopt an approach of choosing the n-gram hash values that are divisible by k. Similarly, some embodiments may choose n-gram hash values that are congruent to some specified integer, modulo k.

Decimation in this manner may provide further memory savings (e.g,. by a factor of about k) and may also save on CPU time (again by a factor of about k). Restraint on increasing k comes from the observation that the number of surviving n-grams must be sufficient to offer the desired discrimination. Suppose that it is concluded that at least m n-grams should be retained. Looking at all the samples {S_(i)} it may be desirable to process,

$k_{i} = {{Max}\left\{ {1,\left\lfloor {\frac{1}{m}{Min}\left\{ {S_{i}} \right\}} \right\rfloor} \right\}}$

may be chosen, where |S_(i)| is the number of n-grams in sample i. In fact, k may be chosen to be the first prime below this value to avoid biases that might be present in hashing n-grams over a small alphabet. For each sample, the set of selected n-gram hash values of that sample may be referred to as the “signature” of the sample.

Decimation may cause issues by virtue of the fact that the decimation factor is constrained by the smallest sample. Indeed, samples may exist that have a length that is less than m, so that no decimation is possible. However, if it is supposed that a dictionary of references is partitioned such that the ith cell contains samples of length L satisfying ρ^(−i)≦L<ρ^(−(i+1)), i=0, 1, 2, . . . , then in order to maintain a minimum number of m n-grams in each reference sample, references in the ith cell can be decimated by k_(i)=Max{1,└ρ^(−i)/m┘}. (Decimation by 1 is equivalent to no decimation at all.) This can result in a huge savings of space, since the longer samples will be decimated more; the total space will be proportional to the number of references, largely independent of their size.

Accordingly, partitioning not only saves time because it reduces the number of candidates to examine, but it also allows custom decimations, resulting in much larger savings in space and time. As mentioned above, a prime value of k may be chosen to avoid biases. Although the scheme suggests that partitions may be created going all the way down to a size of 1, in practice, all cells that hold sizes smaller than m may be grouped together, since they forbid decimation.

FIG. 7 illustrates a flow diagram of one example process employing an exemplary embodiment. In operation 710, design parameters may be accepted and recorded for subsequent steps to use; these parameters may include N, which specifies the n-gram size, M, which specifies the minimum desired number of n-grams per signature, and T, which specifies the score threshold.

A reference library (which may be provided in memory or the storage device 54) may be initialized at operation 720. The details of the initialization may depend on the chosen structure of the library. The library may include a plurality of library cells, each of which may include its decimation factor, summary records for reference samples stored there filed under their respective unique reference sample IDs, and reference sample IDs indexed by n-gram hash values. Each n-gram value index may have any number of reference sample IDs stored under it.

Once library initialization is completed, operation 730 may be executed to ensure that each reference sample is processed according to operation 740, which is amplified below.

Upon completion of reference processing, operation 750 may ensure that each test sample is processed according to operation 760, which is amplified below. It should be understood that operation 750 may process all test samples on hand and then reach completion, or may process test samples as they become available, perhaps over a protracted period.

FIG. 8 illustrates a block diagram showing details of operation 740 above, in which a reference sample is processed, in accordance with an example embodiment. In this regard, at operation 805, a unique identity is assigned to the reference sample, denoted ID herein. A full signature of the reference sample is then produced at operation 810. The full signature may include the set of hash values of the n-grams of size N present in the reference sample. The set of hash values may be produced by recursive n-gram hashing of the sample, or may be obtained by other means. Once the size of the full signature is known, a library cell may be determined at operation 815, identified by a cell index C equal to the integer portion of the negative of the logarithm, base T, of the maximum of M and the full signature size. As an example, for a choice of T=0.5 and M=100, a full signature size of 2000 would result in a library cell of 10, a full signature size of 200 would result in a library cell of 7, and a full signature size of 20 would result in a library cell of 6.

Once the library cell is chosen, the library is consulted at operation 820 to see if the library cell is new. If it is, then the library cell is initiated at operation 825, which includes recording the cell's decimation factor, equal to the maximum of 1 and the nominal decimation factor. The nominal decimation factor may be the integer portion of the ratio of the nominal low range of the library cell and M. The nominal low range of the library cell may be the reciprocal of T raised to the power of the cell's index. The remaining details of initialization may vary with the structure used for the cell. An alternative choice for the cell's decimation factor may be the greatest prime number less than or equal to the value given above.

In operation 830, the cell's decimation factor K may be obtained from the reference library cell. A signature count for the sample may be initialized to zero at operation 833. Operation 835 may ensure that each n-gram hash value V in the full signature of the reference sample produced by operation 810 is examined by operation 840 to see if it is congruent to 0 modulo K. If it is, then the reference's identity ID is recorded under the value V in the library cell at operation 845 and the reference sample's signature count is incremented at operation 847. To complete the recording process, operation 850 builds and records a summary record for the reference sample under the reference's identity ID. This record includes the sample's signature count and any information useful for labeling and specifying the provenance of the reference sample.

FIG. 9 illustrates an alternative embodiment of operation 740, in which a reference sample is processed, and includes many of the same steps as the embodiment illustrated in FIG. 8. This example embodiment obviates the need to construct a full signature of the reference sample. In this embodiment, operations 860 and 862 replace operations 810 and 815 and operation 875 replaces operation 835. Operation 860 estimates the size of the full signature without needing to produce the full signature. For example, the number of tokens in the reference sample may be taken as an estimate of the number of n-grams that would constitute the full signature. Once this estimate is obtained, operation 862 involves choosing a library cell by computing a library cell index C equal to the integer portion of the negative of the log, base T, of the maximum of M and of the estimate of the size of the full signature.

Operation 875 iterates through all n-grams in the reference sample, producing a hash value of each and subjecting the resulting hash values to processing by operations 840, 845 and 847 in the same manner as in the embodiment illustrated in FIG. 8. In should be understood that operation 875 may produce the n-gram hash values without enumerating the n-grams explicitly, such as is done with recursive hashing.

FIG. 10 illustrates a more detailed explanation of operations that may be further involved in operation 760 above, in which a test sample is processed. Operation 900 may involve production of a full signature of the test sample, which may include the set of hash values of the n-grams of size N present in the test sample. The set of hash values may be produced by recursive n-gram hashing of the sample, or may be obtained by other means. Once the size of the full signature is known, operation 905 may include determining the set of library cells that should be queried. This determination may be based on the nominal cell index for the sample, identified by a cell index C0 equal to the integer portion of the negative of the logarithm, base T, of the maximum of M and the full signature size. The set of library cells, identified by their indices, is then {C0−1, C0, C0+1}.

Operation 910 may then include ensuring that for each existing library cell in the set of library cells identified by operation 905, the library cell is queried. It should be understood that the set of library cells identified by operation 905 may include cells that have not been created; such cells are ignored by operation 910.

The querying of a library cell begins with operation 915, which extracts the decimation factor K from the cell. In operation 917, a common n-gram hash counts table is initialized. This will record integer counts filed under reference sample IDs. For each n-gram hash value V in the full signature (operation 920), V is examined by operation 925 to determine if it should be used by seeing if it is congruent to zero modulo K. If so, operation 930 looks up the entry in the library cell filed under V, thereby identifying candidate references and incrementing their counts, as amplified in FIG. 11.

When operation 920 is completed, each key in the common n-gram hashes table constitutes a candidate reference R; operation 940 iterates through these candidates so that each in turn is considered as a possible match to the test sample. Consideration begins by computing the similarity score between R and S in operation 945. The score is based on the common n-gram hash count SR for R, produced in operation 930, and is equal to SR divided by SS+RR−SR, where SS is the size of the test sample's decimated signature and RR is the size of the reference sample's decimated signature, obtained from the reference sample's signature count in the reference sample's summary record. If the resulting score meets or exceeds the threshold (operation 950) then in operation 955 the match between S and R, together with their similarity score, is reported.

FIG. 11 amplifies operation 930 (increment counts for reference indices found in cell under V). An n-gram hash value V is used as a key to obtain a set of reference sample IDs in operation 1000. These are the reference IDs that were recorded in operation 845 under the value V in the current library cell. Operation 1010 loops through each reference sample ID R in the set of reference sample IDs. If R has not yet shared an n-gram hash with this sample, then an entry in the common n-gram hashes table will not exist under R and operation 1015 will direct operation 1020 to record a 1 value as the count for R in common n-gram hashes table; otherwise, operation 1025 will increment the count under R in the common n-gram hashes table.

FIG. 12 illustrates an alternative example embodiment of operation 760 (process test sample), which comprises many of the same steps as the example embodiment illustrated in FIG. 10. In FIG. 12, operations 1050 and 1060 replace operations 900 and 905 and operation 1070 replaces operation 920. This embodiment obviates the need to construct a full signature of the test sample. Operation 1050 estimates the size of the full signature without needing to produce the full signature. For example, the number of tokens in the test sample may be taken as an estimate of the number of n-grams that would constitute the full signature. Once this estimate is obtained, operation 1060 determines the set of library cells that should be queried. This is based on the nominal cell index for the sample, identified by a cell index C0 equal to the integer portion of the negative of the logarithm, base T, of the maximum of M and the estimated full signature size. The set of library cells, identified by their indices, is then {C0−1, C0, C0+1}. Operation 1070 iterates through each n-gram in the sample and produces the hash value of that n-gram. It should be understood that operation 1070 may produce the n-gram hash values without enumerating the n-grams explicitly, such as is done with recursive hashing.

FIG. 13 illustrates an example embodiment that may be well suited to treating all samples as both reference samples and test samples, and doing so as they become available. This embodiment uses many of the same steps as the embodiment illustrated in FIG. 7. The method begins by accepting design parameters in operation 710 and initializing the reference library in operation 720, described above. Operation 1120 waits for new samples to be presented to the apparatus. When they arrive, operation 1130 directs processing on each until they are exhausted, and control returns to operation 1120. Under the direction of operation 1130, each sample is first processed as a test sample using operation 760 described above, so that any matches between the new sample and all samples that came before may be detected and reported. Thereafter, the new sample is treated as a reference sample and processed by operation 740, described above, to record its information in the reference library. A variant of the embodiment illustrated in FIG. 13 may combine steps 760 and 740 so that common work need not be performed twice.

FIG. 14 illustrates a preferred embodiment of my invention that accommodates both reference samples and test samples as they become available. This embodiment uses many of the same steps as the embodiment illustrated in FIG. 7 and FIG. 13. The method begins by accepting design parameters in operation 710 and initializing the reference library in operation 720, described above. After that, two processes continue asynchronously. One process, comprising the operations 1120, 1130, and 740 handles reference samples; the other process, comprising operations 1150, 1160, and 760 handles test samples.

Operation 1120 awaits the arrival of reference samples. When reference samples have arrived, operation 1130 iterates through them, processing each using operation 740 described above. When it has exhausted the new reference samples, it returns to operation 1120 to await further reference samples. Operation 1150 awaits the arrival of test samples. When test samples have arrived, operation 1160 iterates through them, processing each using operation 760 described above. When it has exhausted the new test samples, it returns to operation 1150 to await further test samples. Although some embodiments described herein use a single n-gram size, some embodiments may accommodate n-grams of mixed size. Although some embodiments described herein use a single threshold for determining partitioning and score acceptance, the thresholds may be different for those two uses. Indeed, other partitioning schemes may be employed that do not partition based on powers of any threshold.

From a technical perspective, the code analyzer 44 (or the scoring module 130 of the code analyzer 44) described above may be used to support some or all of the operations described above. As such, the platform described in FIGS. 2 and 6 may be used to facilitate the implementation of several computer program and/or network communication based interactions. As an example, FIGS. 15 and 17 each provide a flowchart of a method and program product according to an example embodiment of the invention. It will be understood that each block of the flowcharts, and combinations of blocks in the flowcharts, may be implemented by various means, such as hardware, firmware, processor, circuitry and/or other device associated with execution of software including one or more computer program instructions. For example, one or more of the procedures described above may be embodied by computer program instructions. In this regard, the computer program instructions which embody the procedures described above may be stored by a memory device of a user terminal (e.g., client 20, application server 40, and/or the like) and executed by a processor in the user terminal. As will be appreciated, any such computer program instructions may be loaded onto a computer or other programmable apparatus (e.g., hardware) to produce a machine, such that the instructions which execute on the computer or other programmable apparatus create means for implementing the functions specified in the flowchart block(s). These computer program instructions may also be stored in a computer-readable memory that may direct a computer or other programmable apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture which implements the functions specified in the flowchart block(s). The computer program instructions may also be loaded onto a computer or other programmable apparatus to cause a series of operations to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus implement the functions specified in the flowcharts block(s).

Accordingly, blocks of the flowchart support combinations of means for performing the specified functions and combinations of operations for performing the specified functions. It will also be understood that one or more blocks of the flowcharts, and combinations of blocks in the flowchart, can be implemented by special purpose hardware-based computer systems which perform the specified functions, or combinations of special purpose hardware and computer instructions.

In this regard, a method according to one embodiment of the invention, as shown in FIG. 15, may include receiving query binary code at operation 1200, processing the query binary code to generate one or more query code fingerprints comprising compressed representations of respective functional components of the query binary code at operation 1210, generating token sequence n-grams of the fingerprints at operation 1220, and hashing the n-grams at operation 1230. In some embodiments, the method may include additional operations such as, for example, partitioning samples by length to compare selected samples based on length at operation 1240, and identifying similarity via dynamic decimation of token sequence n-grams at operation 1250.

In an example embodiment, an apparatus for performing the method of FIG. 10 above may comprise a processor (e.g., the processor 52) or processing circuitry configured to perform some or each of the operations (1200-1250) described above. The processor may, for example, be configured to perform the operations (1200-1250) by performing hardware implemented logical functions, executing stored instructions, or executing algorithms for performing each of the operations. In some embodiments, the processor or processing circuitry may be further configured for additional operations or optional modifications to operations 1200 to 1250. In this regard, for example, processing the reference binary codes may include converting the reference binary codes into source code (or other functional representation code) and breaking the source code into individual functions. In some cases, processing the reference binary code may further include assigning a respective token to each corresponding unit portion of each respective one of the individual functions, and mapping each token to a character to define an ordered string of characters that form the compressed representation.

Locally installed antivirus protection may employ portions or all of example embodiments, or may provide inputs to example embodiments for processing and analysis. Network operations center operators that are not necessarily skilled analysts may utilize tools of an example embodiment to identify software or binaries that should be further analyzed by skilled analysts as part of a seamless environment that enables drill down capabilities and various levels of analytical tools to be employed (e.g., via the network 30). Accordingly, data and visualizations that support immediate analytical needs for both rapid response and back end analysis and update may be provided.

Example embodiments may therefore enable efficient searching for binary files by preprocessing all binaries that are to be searched (e.g., reference binaries) and preprocessing a query binary in the same manner Similarity measurements or scores may then be performed on similarly compressed representations of the functional portions of binaries or text samples. Reports may be generated to indicate the reference functions of portions analyzed, the binaries or other texts from which they came, any similar (or the most similar) binaries/texts to analyzed binaries/texts, and/or the like. The reports may be able to identify which parts of the code are standard or have been seen previously, and which parts appear to be altered or new. The total number of functions reported can be limited, as desired. Thus, for example, only the top ten scores could be reported. Alternatively, example embodiments may use a more absolute notion of similarity and report all functions that are determined to be similar to a query function. However, similarity must be defined in such a context. Thus, for example, a threshold similarity measure or score may be defined so that when the threshold score is reached, the corresponding functions are considered to be similar. Other approaches may also be undertaken.

Using the similarity measurement and scoring technique described above, malware and other specific types of programming code or even text of interest may be identified based on its similarity to other known malware or reference files. However, the similarity measurement and scoring techniques used herein further simplify and reduce the resources needed to effectively perform these tasks. By further managing the contents of the code fingerprint database 230 (e.g., of FIG. 3 above), even further efficiency may be obtained.

In this regard, FIG. 16 illustrates an example embodiment in which the platform described above in relation to FIG. 3 is modified for improved efficiency. FIG. 16 includes substantially similar components, and may function similarly to the descriptions provided above in relation to explaining the example of FIG. 3. However, the example of FIG. 16 further employs a library manager 1300 of an example embodiment. Instead of the reference code fingerprints 220 simply being stored directly in the code fingerprint database 230, the library manager 1300 of an example embodiment may analyze the reference code fingerprints 220 to ensure that any substantial or near duplicates therein are removed. Thus, only non-duplicate reference code fingerprints 1310 are actually stored in the code fingerprint database 230. This means that the overall size of the code fingerprint database 230 can be smaller (thereby saving hardware resources) and that the number of potential matches with query fingerprints 270 may also be reduced (thereby saving bandwidth).

The library manager 1300 may be a component of the code analyzer 44, or may stand apart from the code analyzer 44 and communicate therewith. In an example embodiment, the processor 52 (or the processing circuitry 50) of FIG. 2 (or a separate instance thereof) may be embodied as, include or otherwise control the library manager 1300, which may be any means such as a device or circuitry operating in accordance with software or otherwise embodied in hardware or a combination of hardware and software (e.g., processor 52 operating under software control, the processor 52 embodied as an ASIC or FPGA specifically configured to perform the operations described herein, or a combination thereof) thereby configuring the device or circuitry to perform the corresponding functions of the library manager 1300 as described herein.

In an example embodiment, the library manager 1300 (or code analyzer 44) may operate to partition data into cells. Each incoming sample (e.g., each reference code fingerprint 220) may be sent to cells representing, at most, three sizes. The cells do not need to interact with each other (due to the nature of the scoring done by the scoring manager 130). If cells become too large, new cells can be generated for the same size objects, at the expense of sending new samples to the new and old cells. Duplicates need not be retained within the cells, since it is sufficient to report their duplication. The library manager 1300 may handle the analysis of data to ensure that duplicates are not retained.

As an example, if a library (e.g., the code fingerprint database 230) is divided into cells (e.g., C(1), C(2), C(3), etc.), all the reference samples (e.g., reference code fingerprints 220) of the smallest lengths may be directed into C(1), all reference samples of a next larger sized group may be directed into C(2), and all reference samples of a next larger sized group may be directed into C(3), etc. An unknown sample having a length that suggests the unknown sample should go into cell C(i) may be compared to library cells C(i−1), C(i) and C(i+1). This limits the number of comparisons that may be undertaken based on size.

The cells may be formed and used independently of each other regardless of the physical structure used to create the cells. Although all cells could be loaded onto the same CPU in some cases, another example embodiment may actually split the cells amongst different CPUs. For example, if each of the cells is fit into memory, then C(1) may be loaded onto one CPU, C(2) may be loaded onto another CPU, and so on. Unknown samples (e.g., new reference code fingerprints 220) may then be streamed to the cells (based on size discrimination) so that a limited number (e.g., three) of cells are investigated for each unknown sample. Each CPU may report matches against the reference samples (e.g., previously stored reference code fingerprints) stored in its respective memory. The respective memories may combine to form the code fingerprint database 230 (i.e., a library of the non-duplicate reference code fingerprints 1310). Thus, although the cells operate independently, the library manager 1300 may operate to ensure that the cells collaborate relative to matching reports from the cells. In an example implementation, Hadoop's map phase may be used to send unknown samples to the corresponding cells, with each cell being a reduce process. The reduce may also load an already constructed library cell in one hideous read. Alternatively, instead of using Hadoop, a real time streaming environment may be employed.

In another example embodiment, if it is assumed instead that some cells do not fit into memory, the library manager 1300 may still function. For example, if it is assumed that C(3) represents a popular size such that C(3) would take nearly three times as much memory as could fit onto a single CPU, then the corresponding cell may be segmented into three parts. The first ⅓ of reference samples may then be recorded into cell C(3,1), the second ⅓ of reference samples may be recorded into cell C(3,2), and the third ⅓ of reference samples may be recorded into cell C(3,3). Each of the sub-cells may then be loaded into a CPU and unknown samples that would have been streamed to C(3) are now streamed to C(3,1), C(3,2) and C(3,3). Again, there is no coordination needed between sub-libraries. Instead, the library manager 1300 need only combine match results. No normalization also need be done since there is no weighting being performed.

In practice, these multi-CPU libraries may be created on the fly as data is accumulated. Thus, for example, if references are streamed into the system and begin to populate libraries, as C(3) fills, C(3) may be regarded as C(3,1) as soon as C(3,2) begins to be populated. Then, as the second ⅓ of reference samples gets full, new reference samples may be directed into cell C(3,3) (perhaps on a third CPU). This process can repeat indefinitely and no knowledge about size distribution needs to be known in advance. Instead, new library cells can be built, and sub-cells formed as needed, in order to meet system needs and enable tracking of such cells for routing purposes.

When multiple sub-cells are created to represent a single library cell, new samples may be directed only to the newest sub-cell for recording, but to all cells for comparison to existing samples. In this way, each sample may be recorded only in one spot, but may be compared to all pertinent samples for matching purposes.

Another advantage of dividing a single cell into sub-cells may be that processing the sub-cells can be less expensive than processing one larger combined cell. There are quadratic terms to processing, meaning that cells containing more samples will, in general, require more time to process each sample. By dividing the cell into sub-cells, the overall processing load may be reduced. Thus, it may not be necessary for only one cell or sub-cell to be hosted on a single computer. Multiple sub-cells may be accommodated on each processing core. An ideal maximum cell size may be selected, and cells may then be created as needed by distributing the cells across as many processing cores as is required to support the implementation. Such a structure may also result in better load balancing.

As discussed above, duplicates (which may include exact matches and near matches based on the scoring processes described herein) need not be retained. Thus, for example, only one sample of a set of duplicates need be recorded in a library cell. As such, if sample A and sample B are duplicates, then sample C should score equally well with sample B and sample A based on operation of the scoring module 130. Based on this fact, if only sample A is recorded, along with the fact that sample A and sample B are duplicates, then the score of sample C with sample B is implicitly known when sample A is scored with sample C. Meanwhile, the additional computational and communication load associated with scoring and reporting the additional pairwise scores in sets of duplicates can be avoided. In this regard, suppose that S is a set of n duplicates. Then scoring all members of S against each other will produce n(n-1)/2 scores of 1 that will need to be computed, transmitted and maintained. This can lead to a very expensive cost if n is a large value. Conversely, if it is only necessary to record that every member of S is a duplicate of one of its members, then it is only necessary to compute, transmit and store n-1 scores.

Note that if sample A and sample B have a score of 1.0, they may be considered to be duplicates even if they are not exactly the same. Note also that it may be desirable to chose to relax the definition of duplicate such that the matching score between sample A and sample B need only exceed some threshold t to be considered as duplicates. Indeed, if the score between A and B is 1-d, then the scores of A and of B against C will not differ by more than d.

Benefits associated with the operation of the library manager 1300 may include the fact that each new sample (e.g., new binaries) need only interact with a portion of the data (namely the portion in the cells to which the new samples are sent). No knowledge of the size distribution of the data is needed beforehand. Furthermore, because duplicates are not retained, a huge savings in terms of memory space, communication volume and recordation of results can also be achieved. The elimination of duplicates can be applied in this context in which the fact that sample A scores well with sample B, and sample B scores well with sample C, guarantees that sample A also scores well with sample C. Thus, the library manager 1300 can apply this technique to scoring of not just binaries, but also to other objects including (but not limited to) sets of n-gram hashes.

Operation of the library manager 1300, as part of the operation of the code analyzer 44, may thus be incorporated into a method similar to that of FIG. 15, but for use with an efficiently constructed reference library. As a result, a method for identifying similarity between query samples and stored samples in an efficiently maintained reference library is shown in FIG. 17. The method may include receiving a first threshold and a second threshold at operation 1400. In some cases, the first threshold may be for determining duplicate samples, and the second threshold may be for determining similarity (e.g., via the method of FIG. 15). Thus, the first threshold (which may be, for example, 95% or greater) may be larger than the second threshold (which may be, for example, 70% or greater). The method may further include receiving a plurality of binary reference samples at operation 1410, and processing each reference sample of the plurality of reference samples at operation 1420. The processing may include operations of assigning each reference sample a respective unique identifier at operation 1421, producing a reference sample fingerprint for each reference sample at operation 1422, and registering each respective unique identifier to reference sample fingerprint pair in a reference library at operation 1423. The registering may include scoring the reference sample fingerprint with each previously stored fingerprint in the reference library to produce a first matching score at operation 1424, if the first matching score meets or exceeds the first threshold for a previously stored fingerprint, determining the reference sample fingerprint to be a duplicate of the previously stored fingerprint and recording only a unique identifier associated with the reference sample fingerprint in the reference library where the unique identifier is marked as a duplicate of the previously stored fingerprint at operation 1425, and otherwise, if the first matching score for every previously stored fingerprint is less than the first threshold, storing a corresponding reference sample unique identifier to reference sample fingerprint pair in the reference library at operation 1426. The method may further include receiving a binary query sample at operation 1430 and processing the binary query sample at operation 1440 via operations including producing a query sample fingerprint from the binary query sample at operation 1441, scoring the query sample fingerprint with each previously stored fingerprint in the reference library to produce a second matching score at operation 1442, and for each previously stored fingerprint for which the second matching score meets or exceeds the second threshold, reporting a corresponding reference sample unique identifier associated with the previously stored fingerprint and the second matching score at operation 1443.

In some cases, operations 1400 to 1426 may essentially prepare the reference library in such a way that it does not include duplicates. Moreover, instead of replacing the original with the new duplicate (which would tend to cause a migration in the identity of the reference sample), example embodiments keep the original. A notation may be made regarding the occurrence of the duplication and the identity of the duplicate. However, the sample used for comparison thereafter will remain the original reference sample. Operations 1430 to 1443 may then use the more efficient reference library to employ the scoring module 130 to generate scores as described above. Fewer communications and processing resources will be consumed by these operations since the duplicates have been removed. Example embodiments may therefore provide a dynamic way to save computation, transportation and storage costs by using distributed processing to accommodate potentially large sets of data efficiently.

It is understood by those skilled in the art that the operations enumerated in the example embodiments may be implemented by any combination of software, firmware, and hardware suited to the application, design constraints, and design figures of merit and that steps may, in many cases, be combined, divided, or reordered, all without deviating from the spirit of this disclosure. Moreover, it should be understood that this disclosure can benefit from implementations that employ parallel computation facilities with multiple threads for the purpose of increasing capacity and reliability; such implementations are anticipated by this disclosure and are within the spirit of example embodiments.

Many modifications and other embodiments of the inventions set forth herein will come to mind to one skilled in the art to which these inventions pertain having the benefit of the teachings presented in the foregoing descriptions and the associated drawings. Therefore, it is to be understood that the inventions are not to be limited to the specific embodiments disclosed and that modifications and other embodiments are intended to be included within the scope of the appended claims. Moreover, although the foregoing descriptions and the associated drawings describe exemplary embodiments in the context of certain exemplary combinations of elements and/or functions, it should be appreciated that different combinations of elements and/or functions may be provided by alternative embodiments without departing from the scope of the appended claims. In this regard, for example, different combinations of elements and/or functions than those explicitly described above are also contemplated as may be set forth in some of the appended claims. In cases where advantages, benefits or solutions to problems are described herein, it should be appreciated that such advantages, benefits and/or solutions may be applicable to some example embodiments, but not necessarily all example embodiments. Thus, any advantages, benefits or solutions described herein should not be thought of as being critical, required or essential to all embodiments or to that which is claimed herein. Although specific terms are employed herein, they are used in a generic and descriptive sense only and not for purposes of limitation. 

That which is claimed:
 1. An apparatus comprising processing circuitry configured to execute instructions for: receiving a first threshold; receiving a plurality of binary reference samples; processing each reference sample of the plurality of reference samples via operations including: assigning each reference sample a respective unique identifier; producing a reference sample fingerprint for each reference sample; and registering each respective unique identifier to reference sample fingerprint pair in a reference library via operations including: scoring the reference sample fingerprint with each previously stored fingerprint in the reference library to produce a first matching score; if the first matching score meets or exceeds the first threshold for a previously stored fingerprint, determining the reference sample fingerprint to be a duplicate of the previously stored fingerprint, and recording only a unique identifier associated with the reference sample fingerprint in the reference library, the unique identifier being marked as a duplicate of the previously stored fingerprint; and otherwise, if the first matching score for each previously stored fingerprint is less than the first threshold, storing a corresponding reference sample unique identifier to reference sample fingerprint pair in the reference library.
 2. The apparatus of claim 1, wherein the processing circuitry is further configured for partitioning the reference library into a plurality of cells, each cell being associated with a corresponding size.
 3. The apparatus of claim 2, wherein the processing circuitry is further configured for receiving a second threshold and processing a binary query sample to determine a second matching score.
 4. The apparatus of claim 3, wherein processing the binary query sample comprises determining a size of the binary query sample and scoring the binary query sample against selected previously stored fingerprints in selected ones of the cells based on the size of the binary query sample.
 5. The apparatus of claim 4, wherein the selected ones of the cells comprise a cell corresponding to the size of the binary query sample and to at least one other adjacent cell.
 6. The apparatus of claim 4, wherein the selected ones of the cells comprise a cell corresponding to the size of the binary query sample and no more than two other adjacent cells.
 7. The apparatus of claim 3, wherein at least one of the cells includes sub-cells, the sub-cells being distributed over corresponding different CPUs.
 8. The apparatus of claim 5, wherein a subsequent sub-cell is dynamically established on one of the corresponding different CPUs responsive to a prior sub-cell being filled.
 9. The apparatus of claim 2, wherein the first threshold is larger than the second threshold.
 10. The apparatus of claim 1, wherein each of the reference samples is a code binary.
 11. The apparatus of claim 1, wherein each of the reference samples is a passage of text.
 12. An apparatus comprising processing circuitry configured to execute instructions for: receiving a binary query sample; processing the binary query sample via operations including: producing a query sample fingerprint from the binary query sample; scoring the query sample fingerprint with each previously stored fingerprint in a reference library to produce a matching score, wherein each previously stored fingerprint in the reference library has been determined, prior to storage, as not being duplicative of another fingerprint in the reference library; and for each previously stored fingerprint for which the matching score meets or exceeds a predetermined threshold, reporting a corresponding reference sample unique identifier associated with the previously stored fingerprint and the matching score.
 13. The apparatus of claim 12, wherein the processing circuitry is further configured for partitioning the reference library into a plurality of cells, each cell being associated with a corresponding size.
 14. The apparatus of claim 13, wherein processing the binary query sample comprises determining a size of the binary query sample and scoring the binary query sample against selected previously stored fingerprints in selected ones of the cells based on the size of the binary query sample.
 15. The apparatus of claim 14, wherein the selected ones of the cells comprise a cell corresponding to the size of the binary query sample and to at least one other adjacent cell.
 16. The apparatus of claim 14, wherein the selected ones of the cells comprise a cell corresponding to the size of the binary query sample and no more than two other adjacent cells.
 17. The apparatus of claim 13, wherein at least one of the cells includes sub-cells, the sub-cells being distributed over corresponding different CPUs.
 18. The apparatus of claim 17, wherein a subsequent sub-cell is dynamically established on one of the corresponding different CPUs responsive to a prior sub-cell being filled.
 19. The apparatus of claim 12, wherein each of the binary query samples is a code binary.
 20. The apparatus of claim 12, wherein each of the binary query samples is a passage of text. 